package com.yunupmall.uits;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class ReturnData {
    public static String getReturnData(Integer counts, List list) {
        Map<String, Object> map = new HashMap<>();
        map.put("code", 0);
        map.put("msg", "");
        map.put("count", counts);
        JSONArray array = JSONArray.parseArray(JSON.toJSONString(list));
        map.put("data", array);
        return JSON.toJSONString(map);
    }

    public static String getNOReturnData(List list) {
        Map<String, Object> map = new HashMap<>();
        map.put("code", 0);
        map.put("msg", "");
        map.put("count", 10);
        JSONArray array = JSONArray.parseArray(JSON.toJSONString(list));
        map.put("data", array);
        return JSON.toJSONString(map);
    }
}
